
def get_ip(req):
    if req.META.get('HTTP_X_FORWARDED_FOR', None):
        ip = req.META['HTTP_X_FORWARDED_FOR']
    else:
        ip = req.META['REMOTE_ADDR']
    return ip


